﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EYangFramework.Common.Ninject
{
    [AttributeUsage(AttributeTargets.Class|AttributeTargets.Interface, AllowMultiple = false, Inherited = true)]
    public class AutoBindAttribute : Attribute
    {
        public bool IsSington = false;
        public Type ServiceType;
        public Type ImpleType;
        public AutoBindAttribute(bool isSington = false) : this(null, null, isSington)
        {
        }
        public AutoBindAttribute(Type impleType, bool isSingotn = false) : this(null, impleType, isSingotn)
        {
        }
        public AutoBindAttribute(Type serviceType, Type impleType, bool isSington)
        {
            if (serviceType != null && (!serviceType.IsInterface || !serviceType.IsAbstract))
            {
                throw new NinjectException("服务基类不是接口或者抽象类!");
            }
            ServiceType = serviceType;
            ImpleType = impleType;
            IsSington = isSington;
        }
    }
}
